#include "DominoBlocks.h"


DominoBlocks::DominoBlocks():PhysicsCube(1,1,1){}
DominoBlocks::DominoBlocks(D3DXVECTOR3 pos,D3DXVECTOR3 rot,D3DXVECTOR3 dim) : PhysicsCube(dim.x,dim.y,dim.z)
{
	Position = pos;
	RotX = rot.x;
	RotY = rot.y;
	RotZ = rot.z;
}

void DominoBlocks::CreateGeometry()
{
	PhysicsCube::CreateGeometry();
	Geometry[0]->SetColor(0.5f, 0.5f, 0.5f);
}

void DominoBlocks::AddObjectToSimulation( hkpWorld* theWorld )
{
	
	PhysicsCube::AddObjectToSimulation(theWorld);

	havokRigidBody->setName("BLOCKS");
}

void DominoBlocks::Init()
{
	PhysicsCube::Init();
}

void DominoBlocks::CreatePhysicsObject()
{
	hkVector4 axis(0,0,0);
	float angle = 0;
	if(RotX > 0)
	{
		axis(0) = 1;
		angle = D3DXToRadian(RotX);
	}
	else if(RotY > 0)
	{
		axis(1) = 1;
		angle = D3DXToRadian(RotY);
	}
	else if(RotZ > 0)
	{
		axis(2) = 0;
		angle = D3DXToRadian(RotZ);
	}

	if(angle > 0)
		bodyInfo.m_rotation.setAxisAngle(axis, angle);
	else
		bodyInfo.m_rotation.setIdentity();

	PhysicsCube::CreatePhysicsObject();


}